<template>
	<div>
		<div class="header">



			<!-- title="智能供佛系统" -->
			<van-nav-bar style="  background: linear-gradient(90deg, #41A9B7,#4fd4e2, #41A9B7);height: 5rem;line-height: 5rem;">
				<span class="title" slot="title">账号登录</span>
				
				<span style="font-size: 1.5625rem ; color: white; font-weight: 500;" slot="right">
					<van-button type="primary" color="#348994" 	@click="back">&nbsp;返&nbsp;&nbsp;&nbsp;回&nbsp;</van-button>
				</span>
			</van-nav-bar>
			<!-- <van-nav-bar title="智能供佛系统" style=" background: url(./images/系统标题部分.png);height: 80px;line-height: 80px; background-size:1142px 80px;background-repeat:no-repeat;">
				<van-icon name="search" slot="right" />
			</van-nav-bar> -->
		</div>


		<!-- /////////////////////////////////////////////////////////// -->
		<div class="content" >

			<div style="width: 31.25rem;  margin: 14rem auto;">

				<span style="color: crimson;font-size: 1rem;">{{mes}}</span>
				<van-cell-group>
					<van-field size="large" @focus="isInput" v-model="phoneNumber" label="用户账号" left-icon="contact" placeholder="请输入您的手机号码">
						<!-- <van-button slot="button" size="small" type="primary">登入</van-button> -->
					</van-field>
				</van-cell-group>

				<van-button color="#2d7a82" size="large" style="margin-top: 20px;" @click="login">登入</van-button>




				<!-- 键盘 -->
				<van-number-keyboard :show="keybord" theme="custom" extra-key="." close-button-text="完成" @blur="keybord = false"
				 @input="onInput" @delete="onDelete"	/>
			</div>



		</div>
	</div>

</template>

<script>
	export default {


		data() {
			return {
				keybord: false,
				phoneNumber: '',
				mes: ''


			}
		},
		methods: {
			back(){
				this.$router.go(-1);
			},
			isInput() {
				this.keybord = true;
			},
			onInput(value) {
				this.phoneNumber += value;
			},
			onDelete() {
				this.phoneNumber = this.phoneNumber.substring(0, this.phoneNumber.length - 1);
			},
			
			
			login() {


				//查找用户
				this.axios.post('https://mianmianshi.com/cms/temple/client/findUser', {

						'where': {
							'phone_number': this.phoneNumber,
							tid:this.$store.getters.getTid|localStorage.tid
						},

					})
					.then((res) => {
						console.log("res:", res);

						if (JSON.stringify(res.data) != "{}") {
							
							this.$toast.success({
								message: '登陆成功！'
							});
							
							
							this.$store.commit('setUser', res.data)//数据都从仓库中取，以下路由传参方式不用了，为无效代码
							
							if (res.data.identity == "ADMIN") {
								this.$router.push({
									path: '/adminPage'
									/* query: res.data */
								}); //this.$route.query用这个去接收参数
							} else if (res.data.identity == "CONSUMER") {
								this.$router.push({
									path: '/consumer'
								/* 	query: res.data */
								}); //this.$route.query用这个去接收参数
							}

						} else {
							this.mes = "账号不存在，请检查是否输入错误";
						}
					})
					.catch(function(error) {
						//this.mes = "未找到该用户，请检查是否输入错误";
						console.log(error);
					});
				//
			}



		},

		created() {

		},
		mounted() {

		}
	}
</script>

<style>
	
</style>
